package com.wyy.controller;

import com.wyy.beans.Ticket;
import com.wyy.service.TicketService;
import com.wyy.common.Result;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api")
public class TicketController {

    @Autowired
    private TicketService ticketService;

    @PostMapping("/ticket")
    @RequiresRoles("admin")
    public Result<Ticket> addTicket(@RequestBody Ticket ticket) {
        return ticketService.addTicket(ticket);
    }

    @GetMapping("/ticket/{licensePlateNo}")
    public Result<Ticket> getTicket(@PathVariable String licensePlateNo) {
        return ticketService.getTicket(licensePlateNo);
    }

}
